/*oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO

Authors: Nitay Megides
		 Rachel Banino

Project: Exercise 1

Using: LinkedList.h
	   General.h
	   Hw1Types.h

Description:
The inventory list is a module encapsulates a linked list containing, logically, the 
inventory of the shop. See the c file documentation for more information.

Notice that:
- The product IDs are sorted from low to high
- The products themselves are also sorted from the low price to the high
oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO*/


#ifndef INVENTORY_LIST_H
#define INVENTORY_LIST_H

#include "General.h"
#include "Hw1Types.h"
#include "LinkedList.h"


/*
 * TInventoryItem - This holds a list of Products sorted by price
 */
typedef struct 
{
    int ProductID;
	PList Products;
} TInventoryItem;
typedef TInventoryItem* PInventoryItem;

/*
 * TInventoryProduct - Holds simply a price, and some pointers to ease development
 */
typedef struct
{
    TMoney Price;
	PListItem ListItem;
	PInventoryItem ProductGroup;
} TInventoryProduct;
typedef TInventoryProduct* PInventoryProduct;

/* InitializeInventoryList()
 * -----------------------------------
 * Allocates and initiaizes the inventory list. MUST BE CALLED PRIOR TO USING THIS MODULE
 * Return TRUE on success, FALSE on failure
 */
BOOL InitializeInventoryList();

/* AddInventoryProduct()
 * -----------------------------------
 * Adds a new product with product id = productID, and price = price
 * Return TRUE on success, FALSE on failure
 */
BOOL AddInventoryProduct(const TProductID productID, const TMoney price);


/* FindInventoryItem()
 * -----------------------------------
 * Return a inventory item with product id = productID. If no product is found, return NULL
 */
PInventoryItem FindInventoryItem(const TProductID productID);


/* GetInventoryProduct()
 * -----------------------------------
 * Return a product with product id = productID, and price no higher (but as close as possible) than highestPrice. If no product is found, return NULL
 */
PInventoryProduct GetInventoryProduct(const TProductID productID, const TMoney highestPrice);

/* RemoveInventoryProduct()
 * -----------------------------------
 * Removes a product from the inventory with the given parameters
 */
void RemoveInventoryProduct(const TProductID productID, const TMoney price);

/* PrintInventoryList()
 * -----------------------------------
 * Prints the content of the inventory
 */
void PrintInventoryList();

/* SaveInventoryList()
 * -----------------------------------
 * Saves a binary copy of the inventory to file determined by filename (The file structure is 
 * described in the instructions for this exercize)
 */
void SaveInventoryList(const char* filename);

/* LoadInventoryList()
 * -----------------------------------
 * Loads inventory from a binary file determined by filename
 */
void LoadInventoryList(const char* filename);

/* FreeInventoryList()
 * -----------------------------------
 * Frees up all this list
 */
void FreeInventoryList();

#endif // INVENTORY_LIST_H